package cn.zhuoluodada.opensource.smartdb.datasource;

import java.io.IOException;
import java.sql.Connection;
import java.sql.SQLException;

/**
 * 只有一个数据源的group
 *
 * @author zhuoluodada@qq.com
 */
public class SingleDataSourceGroup implements SmartDbDataSourceGroup {

    private SmartDbDataSource dataSource;

    public SingleDataSourceGroup(SmartDbDataSource dataSource) {
        this.dataSource = dataSource;
    }

    @Override
    public Connection getConnection(OptEnum opt) throws SQLException {
        return dataSource.getConnection();
    }

    @Override
    public void releaseConnection(OptEnum opt, Connection connection) {
        if (connection != null) {
            dataSource.releaseConnection(connection);
        }
    }

    @Override
    public void close() throws IOException {
    }
}
